package org.example.controller;

import org.example.bean.User;
import org.example.service.ServiceTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/user")
class PersonController {

    @Resource
    private User user;

    @Resource
    private ServiceTest serviceTestImpl;

    @GetMapping("/add")
    @ResponseBody
    public String add(@RequestBody User user) {
        serviceTestImpl.helloService();
        System.out.println(user);
        return "<h1>hello</h1>";
    }
    @GetMapping("/{id}")
    @ResponseBody
    public List<User> getPerson(@PathVariable Long id) {
        List<User> userList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            userList.add(user);
        }
        return userList;
    }

}